<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>遍历数组</title>
    <script>
        var arr = ["孙悟空","猪八戒","沙和尚"];

        //使用for遍历数组
        for(var i = 0; i<arr.length;i++){
            console.log(arr[i]);
        }


        //使用forEach（）方法遍历数组
        arr.forEach(function(value,index,obj){
            console.log(value);
            console.log(index);
            console.log(obj);

        });

        
    </script>
</head>
<body>
    
</body>
</html>